//
//  ViewController.swift
//  LayoutDemo
//
//  Created by 万孟超 on 2024/3/14.
//

import UIKit
import CSLayout

class ViewController: UIViewController {
    
    lazy var firstView = {
        let first = UIView()
        first.backgroundColor = .red
        return first
    }()
    
    lazy var secondView = {
        let second = UIView()
        second.backgroundColor = .blue
        return second
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        installSubviews()
    }

    func installSubviews() {
        view.addSubview(firstView)
        firstView.csl.makeConstraints { maker in
            maker.leading.equalToSuperview().offset(50)
            maker.top.equalToSuperview().offset(100)
            maker.size.equalTo((100, 100))
        }
        
        view.addSubview(secondView)
        secondView.csl.makeConstraints { maker in
            maker.leading.greaterThanOrEqualTo(firstView.csl.trailing).offset(10)
            maker.trailing.greaterThanOrEqualToSuperview().offset(-20)
            maker.top.equalTo(firstView)
            maker.size.equalTo(firstView).mutiplierBy(3)
        }
        
    }

}

